package com.king.juc.atomicdemo.fieldupdater;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/**
 * @author king
 * @date 2020/12/1 13:56
 */
public class FieldDemo {
    public static void main(String[] args) {
        Student student = new Student();
        AtomicReferenceFieldUpdater fieldUpdater =
                AtomicReferenceFieldUpdater.newUpdater(Student.class, String.class, "name");

        System.out.println(fieldUpdater.compareAndSet(student, null, "张三"));
        System.out.println(student);
    }
}
